﻿using IBll;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Model;

namespace WebApi.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class StareController : ControllerBase, IStareBll
    {
         public StareController(IStareBll bll)
        {
            Bll = bll;
        }



        public IStareBll Bll { get; }

        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="stare">房型表</param>
        /// <returns>往房型表里面添加数据</returns>
        /// 
        [HttpPost]
        public Task<int> AddAnyns(Stare stare)
        {
            try//异常处理
            {
                return Bll.AddAnyns(stare);

            }
            catch (Exception)
            {

                throw;
            }
        }

        /// <summary>
        /// 返填
        /// </summary>
        /// <param name="id">主键id</param>
        /// <returns>通过id获取一条信息</returns>
        /// 
        [HttpGet]
        public Stare FindStare(int id)
        {
            try//异常处理
            {
                return Bll.FindStare(id);

            }
            catch (Exception)
            {

                throw;
            }
        }
        /// <summary>
        /// 查询分页
        /// </summary>
        /// <param name="name">房型名称</param>
        /// <param name="maxstareMax">房型大小</param>
        /// <param name="minstareMax">房型大小</param>
        /// <param name="index">页数</param>
        /// <param name="size">条数</param>
        /// <returns>查询数据</returns>
        /// 
        [HttpGet]
        public StareDto ShowStare(string? name, int? maxstareMax, int? minstareMax, int index, int size)
        {
            try//异常处理
            {
                return Bll.ShowStare(name, maxstareMax, minstareMax, index, size);



            }
            catch (Exception)
            {

                throw;
            }
        }




        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="stare">房型表</param>
        /// <returns>往房型表里面添加数据</returns>

        [HttpPost]
        public Task<int> UpdateAnyns(Stare stare)
        {
            try//异常处理
            { 
                 return Bll.UpdateAnyns(stare);


            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
